//
//  DevicePhoneTableViewCell.m
//  NuwaRobot
//
//  Created by Kendama on 2017/12/2.
//  Copyright © 2017年 Kendama. All rights reserved.
//

#import "DevicePhoneTableViewCell.h"

@implementation DevicePhoneTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.backgroundColor = rgba(27,44,81,1);
        [self masLayoutSubview];
    }
    return self;
}

- (void)didClickCallButton
{
    if (self.CallBlock)
    {
        self.CallBlock();
    }
}

- (UILabel *)titleLabel
{
    if(!_titleLabel)
    {
        UIView *superView = self.contentView;
        _titleLabel = [[UILabel alloc]init];
        [superView addSubview:_titleLabel];
        [_titleLabel setFont:fontCommonSize];
        [_titleLabel setTextColor:[UIColor whiteColor]];
    }
    return _titleLabel;
}
- (UIButton *)callButton
{
    if(!_callButton)
    {
        UIView *superView = self.contentView;
        _callButton = [[UIButton alloc]init];
        [superView addSubview:_callButton];
        [_callButton setBackgroundImage:imageWithName(@"icon_phone call ") forState:UIControlStateNormal];
        [_callButton addTarget:self action:@selector(didClickCallButton) forControlEvents:UIControlEventTouchUpInside];
    }
    return _callButton;
}

- (void)masLayoutSubview
{
    __weak UIView *superView = self.contentView;
    [self.callButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(superView.mas_centerY);
        make.right.mas_equalTo(superView.mas_right).with.offset(-px1080Width(40));
        make.height.width.mas_equalTo(px1920Height(150));
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(superView.mas_left).with.offset(px1080Width(40));
        make.right.mas_equalTo(self.callButton.mas_left);
        make.centerY.mas_equalTo(superView.mas_centerY);
        
    }];
}

@end
